package com.vilinno.tlias.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class AOPDemoAspect {

    @Around("execution(* com.vilinno.tlias.service.impl.*.*(..))")
    public Object recordTime(ProceedingJoinPoint joinPoint) throws Throwable {

        //1. 记录开始时间
        Long begin=System.currentTimeMillis();

        //2. 执行原有方法
        Object obj=joinPoint.proceed();

        //3. 记录结束时间
        Long end=System.currentTimeMillis();
        log.info("业务方法执行耗时：{}ms",end-begin);

        return obj;
    }

}
